<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%
  String basePath=request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+"/";
%>
<html>
  <head>
    <base href="<%=basePath%>">
    <title>个人管理界面</title>
    <meta charset="UTF-8">

    <link href="css/admin/personInfo.css" rel="stylesheet" type="text/css" />
    <%-- 引入jquery --%>
    <script type="text/javascript" src="jquery/jquery-1.11.1-min.js"></script>

    <%--  引入bootstrap框架--%>
    <link href="jquery/bootstrap_3.3.0/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="jquery/bootstrap_3.3.0/js/bootstrap.min.js"></script>

    <%-- 引入Bootstrap datetimepicker插件 --%>
    <link href="jquery/bootstrap-datetimepicker-master/css/bootstrap-datetimepicker.min.css" type="text/css" rel="stylesheet" />
    <script type="text/javascript" src="jquery/bootstrap-datetimepicker-master/js/bootstrap-datetimepicker.js"></script>
    <script type="text/javascript" src="jquery/bootstrap-datetimepicker-master/locale/bootstrap-datetimepicker.zh-CN.js"></script>

    <script type="text/javascript">
        $(function (){
          // 当容器加载完成之后，对容器调用工具函数
          $("#userBirthUpdate").datetimepicker({
            language:'zh-CN', // 语言 中文
            format:'yyyy-mm-dd', // 日期格式
            minView:'month', // 可以选择的最小视图
            autoclose:true, // 设置选择完日期后是否自动关闭日历，默认是false
            initalDate:new Date(), // 初始化显示的日期
            todayBtn:true, // 表示是否显示今天按钮，默认是false
            clearBtn:true, // 设置是否显示清空按钮，默认是false
            pickerPosition:'top-left'
          });

            // 给修改按钮添加单机时间
            $("#updateUserBtn").click(function (){
                // 收集参数
                var adminId = $.trim($("#userId").val());
                var adminAccount = $.trim($("#userAccountUpdate").val());
                var adminName = $.trim($("#userNameUpdate").val());
                var adminSex = $.trim($("#userSexUpdate").val());
                var adminPassword = $.trim($("#userPasswordUpdate").val());
                var adminPasswordRe = $.trim($("#userPasswordReUpdate").val());
                var adminBirth = $.trim($("#userBirthUpdate").val());
                // 表单验证
                if(adminPasswordRe!=adminPassword){
                    alert("请确定两次是否相同");
                    return;
                }
                // 发送请求
                $.ajax({
                    url:'workbench/admin/person/updateAdminInfo.do',
                    data:{
                      adminId:adminId,
                      adminAccount:adminAccount,
                      adminName:adminName,
                      adminPassword:adminPassword,
                      adminSex:adminSex,
                      adminBirth:adminBirth
                    },
                    type:'post',
                    dataType:'json',
                    success:function (data){
                        if(data.code=="1"){
                            // 重新登录
                            window.parent.location.href='workbench/admin/exit.do';
                        }else{
                            alert(data.message);
                        }
                    }
                })
            });
        });
    </script>
  </head>

  <body>
    <div class="body_right">
        <div  id="myModalUpdate">
          <div id="search_update">
            <div id="search_body_update">
              <form method="post" action="#">
                <input type="hidden" id="userId" value="${admin.adminId}">
                <div>
                  <label>账号</label>
                  <input class="in" type="text" id="userAccountUpdate" value="${admin.adminAccount}" readonly="readonly"/>
                </div>
                <div>
                  <label>姓名</label>
                  <input class="in" type="text" id="userNameUpdate" value="${admin.adminName}"/>
                </div>
                <div>
                  <label>性别</label>
                  <select class="search-in" id="userSexUpdate">
                    <c:if test="${admin.adminSex=='0'}">
                      <option value="1">男</option>
                      <option value="0" selected>女</option>
                    </c:if>
                    <c:if test="${admin.adminSex=='1'}">
                      <option value="1" selected>男</option>
                      <option value="0">女</option>
                    </c:if>
                  </select>
                </div>
                <div>
                  <label>密码</label>
                  <input class="in" type="password" id="userPasswordUpdate" value="${admin.adminPassword}"/>
                </div>
                <div>
                  <label>确认密码</label>
                  <input class="in" type="password" id="userPasswordReUpdate" value="${admin.adminPassword}"/>
                </div>
                <div>
                  <label>出生日期</label>
                  <input class="in" type="text" id="userBirthUpdate" value="${admin.adminBirth}"/>
                </div>
                <div>
                  <input id="updateUserBtn" type="button" value="修改"/>
                </div>
              </form>
            </div>
          </div>
        </div>
    </div>
  </body>
</html>
